package com.doit.day01;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooKeeper;

import java.util.List;

/**
 * 递归删除文件夹
 */
public class RMRDemo {
    public static void main(String[] args) throws Exception {
        //创建zk的对象
        ZooKeeper zk = new ZooKeeper("linux01:2181",2000,null);
        rmr("/teacher",zk);
        zk.close();
    }


    public static void rmr(String path,ZooKeeper zk) throws Exception {
        List<String> children = zk.getChildren(path, null);
        if (children != null && children.size() >0){
            for (String child : children) {
                rmr(path+"/"+child,zk);
                System.out.println("正在删除的子节点是："+path+"/"+child);
            }
        }
    }
}
